﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ParsingProject
{
    public class FileLayoutParser : IParser
    {
        public List<List<string>> Parse(string path)
        {
            List<List<string>> result = new List<List<string>>();
            List<string> header = new List<string>();

            header.Add("Column Name");
            header.Add("Column Type");
            header.Add("Length");
            header.Add("Description");

            result.Add(header);

            if (!ParserHelper.ReadFile(path))
                return null;

            while (!ParserHelper.EndOfStream(path))
            {
                List<string> line = new List<string>();
                string[] cells = ParserHelper.ReadAndParseLine(path, 4);
                line.AddRange(cells);
                result.Add(line);
            }

            ParserHelper.CloseReadFile(path);

            return result;
        }
    }
}
